package com.nbstar.film.spider.http;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.util.zip.GZIPInputStream;

public class ZipParser implements HttpResultParserAdaper {
    @Override
    public String parseResult(HttpURLConnection conn) throws IOException {
        StringBuilder result =  new StringBuilder();

        InputStream stream = new GZIPInputStream(conn.getInputStream());
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream,"utf-8"));
        String line = "";
        while ((line = reader.readLine()) != null){
            result.append(line + "\r\n");
        }

        reader.close();
        stream.close();
        return result.toString();
    }
}
